<?xml version="1.0" encoding="utf-8" ?>

[#include "/WEB-INF/pages/common/taglibs.ftl"]
[#assign act="update" ]
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Model</title>
	<meta name="menu" content="CategoryMenu"/> 
	<meta name="heading" content="heading"/>
	
	<script type="text/javascript" src="[@c.url value='/js/plugins/jquery.alerts.js'/]"></script>
	<script type="text/javascript">
		var base = (function(){
				// 事件绑定
				function _addEventListeners() {
					// 新建事件绑定
					var formId = '${(form.id)!''}';
					$('input[act=add]', 'li').click(function(){
						var url = "[@c.url value='/manage/FormArticle_createItem.action'/]";
						$.get(url, {id:formId, ajax:'true'}, function(result){
							$(result).dialog({
								height: 140,
								width: 500,
								modal: false
							});
						})
					})
					
					// 修改事件绑定
					$('a[act=upt]', 'li').click(function(){
						var id = $(this).attr('val');
						var url = "[@c.url value='/manage/FormArticle_editItem.action'/]";
						$.get(url, {id : id, ajax : 'true'}, function(result){
							$(result).dialog({
								height: 140,
								width: 500,
								modal: false
							});
							$('#formItemSubmit', $(result)).click(function(){
								alert(1)
								$('#formItemTable').wrap(function(){
									return "<form action='[@c.url value='/manage/formItem.action' /]' method='post'>" + $(this).html() + "</form>";
								});
								alert($('#formItemTable').html());
							})
						})
					})
					// 删除事件绑定
					$('a[act=del]', 'li').click(function(){
						var id = $(this).attr('val');
						var title = $('#delete-confirm').attr('title');
						var content = $('#delete-confirm').html();
						jConfirm(content, title, function(r) {
							if (r) {
								[@c.url	var="deleteUrl" value='/manage/FormArticle_deleteItem.action' scope="page"]
									[@c.param name="id" value="" /]
								[/@c.url]
								window.location	= "${deleteUrl}" + id;
							}
						});
						return false;
					})
				}
				return {
	                config: {
	                    theme: null
	                },
	                init: function () {
	                	_addEventListeners();
	                }
				}
			}());
		
			$(function(){
				base.config.url = "[@s.url value='/manage/FormArticle_list.action'][/@s.url]";
				base.config.renderTo = "#formArticle";
				base.config.theme = getTheme();
	            //Initializing the form
            	base.init();		
			})
		</script>
</head>
<body id="body">
	<div class="contenttitle">
    	<h2 id="vertical" class="form"><span>自定义表单</span></h2>
    </div><!--contenttitle-->
		<form action="[@c.url value='/manage/FormArticle_${act}.action?backurl=${action.currentUrl}'/]" method="post">
			<input type="hidden" name="id" value="${id}"/>
			<input type="hidden" name="form.id" value="${(form.id)!''}"/>
			<table cellspacing="0" cellpadding="0" border="0" class="stdtable-form">
				<thead>
					<tr>
						<th class="head0"></th>
						<th class="head1"></th>
						<th class="head0"></th>
						<th class="head1"></th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td style="width:65px">名称：</td>
						<td><input type="text" class="smallinput" placeholder="?" name="form.name" value="${(form.name)!''}"/></td>
						
						<td>标题：</td>
						<td><input type="text" class="smallinput" placeholder="?" name="form.title" value="${(form.title)!''}"/></td>
					</tr>
					<tr>
						<td>权限：</td>
						<td><input type="text"  placeholder="?" name="form.ownerSsid" value="${(form.ownerSsid)!''}"/></td>
						<td>状态：</td>
						<td>
	            		可用： <input type="radio" id="form_enabled_T" name="form.enabled" value="true" [#if form == null || (form.enabled ==true)]checked[/#if]/>
						禁用 ：<input type="radio" id="form_enabled_F" name="form.enabled" value="false" [#if (form != null && form.enabled == false)]checked[/#if]/>
						</td>
					</tr>
					<tr>
						<td colspan=4><hr></td>
					</tr>
					<tr>
						<td>基础字段：</td>
						<td colspan=3>
							<ul>
							[#list formItemList as item]
								<li style="margin:2px 1px;"> <input type="hidden" name="form.formItemList[${item_index}].id"  value="${item.id}"/>
									&nbsp;&nbsp;名称：<input type="text" name="form.formItemList[${item_index}].name" value="${item.name}"/>
									&nbsp;&nbsp;标题：<input type="text" name="form.formItemList[${item_index}].title" value="${item.title}"/>  
									&nbsp;&nbsp;排序：<input type="text" style="width:25px" name="form.formItemList[${item_index}].priority" value="${(item.priority)!0}"/>
									&nbsp;&nbsp;显示：<input type="checkbox" name="form.formItemList[${item_index}].enabled" value="true" [#if item.enabled == true]checked[/#if]/>
									[#--&nbsp;&nbsp;<a href="javascript:void(0);" act='upt' val='${item.id}'>修改</a>&nbsp;&nbsp;<a href="javascript:void(0);" act='del' val='${item.id}'>删除</a>--]
								</li>
							[/#list]
							</ul>
						</td>
					</tr>
					
					<tr>
						<td>扩展字段：</td>
						<td colspan=3>
							<ul>
								<li style="margin:2px 1px 8px 38px;">
									<input type="button" name="" value="增加新字段" act="add" />
								</li>
							[#list formCustomItemList as item]
								<li style="margin:2px 1px;"> <input type="hidden" name="form.formItemList[${(formItemList.size()+item_index)}].id"  value="${item.id}"/>
									&nbsp;&nbsp;名称：<input type="text" name="form.formItemList[${(formItemList.size()+item_index)}].name" value="${item.name}"/> 
									&nbsp;&nbsp;标题： <input type="text" name="form.formItemList[${(formItemList.size()+item_index)}].title" value="${item.title}"/>
									&nbsp;&nbsp;排序：<input type="text" style="width:25px" name="form.formItemList[${(formItemList.size()+item_index)}].priority" value="${(item.priority)!0}"/>
									&nbsp;&nbsp;显示：<input type="checkbox" name="form.formItemList[${(formItemList.size()+item_index)}].enabled" value="true" [#if item.enabled == true]checked[/#if]/>
									&nbsp;&nbsp;<a href="javascript:void(0);" act='upt' val='${item.id}'>修改</a>&nbsp;&nbsp;<a href="javascript:void(0);" act='del' val='${item.id}'>删除</a>
								</li>
							[/#list]
							</ul>
						</td>
					</tr>
					<tr>
						<td></td>
						<td colspan=3>
							<button class="submit ">提&nbsp;&nbsp;交</button>
							<input type="reset" class="reset radius2" value="重&nbsp;&nbsp;置">
							<a style="margin-left: 6px; background-color: rgb(247, 247, 247); border-color: rgb(204, 204, 204); color: rgb(51, 51, 51);" href="${action.backurl}" class="anchorbutton button_alert">
								<span style="line-height: 21px; background-color: rgb(255, 255, 255); border-color: rgb(221, 221, 221);">返&nbsp;&nbsp;回</span>
							</a>
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	<div style="clear:both;"></div>
	<div id="delete-confirm" style="display:none" title="删除栏目">
		<p>自定义表单删除后将无法恢复.</p>
		您确认删除吗？
	</div>
</body>
</html>
